﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.SEO.Model;
using com.SEO.DataAccess;

namespace Helper.Bussiness
{
    public class KeywordManage : BaseManage
    {
        public int AddkeywordInfo(KeywordInfo info, string connName = ConnectionName)
        {

            KeywordCtrl ctrl = new KeywordCtrl();
            return ctrl.Insert(connName, info);
        }

        public int UpdateKeywordInfo(KeywordInfo info, string connName = ConnectionName)
        {
            KeywordCtrl ctrl = new KeywordCtrl();
            return ctrl.UpDate(connName, info);
        }

        public KeywordInfo GetKeywordInfoByID(string objectID, string connName = ConnectionName)
        {
            KeywordCtrl ctrl = new KeywordCtrl();
            List<KeywordInfo> lstKeywordInfo = ctrl.SelectAsList(connName, " KeywordID = '" + objectID + "'");
            if (lstKeywordInfo.Count > 0)
            {
                return lstKeywordInfo[0];
            }

            return null;
        }

        public List<KeywordInfo> GetKeywordInfoByCondition(string strCondition, string connName = ConnectionName)
        {
            KeywordCtrl ctrl = new KeywordCtrl();
            return ctrl.SelectAsList(connName, strCondition);
        }

        public void DeleteKeywordInfo(KeywordInfo info, string connName = ConnectionName)
        {
            KeywordCtrl ctrl = new KeywordCtrl();
            ctrl.Delete(connName, info.KeywordId.ToString());
        }

        public void DeleteKeywardBySiteID(string objectID, string connName = ConnectionName) {

            KeywordCtrl ctrl = new KeywordCtrl();
            ctrl.DeleteBySiteID(connName, objectID);
        }
    }
}
